package org.codert.jpa.domain.order;

import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.codert.jpa.domain.AbstractEntity;
import org.codert.jpa.domain.person.User;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.List;

/**
 * @author: TanJingyu
 * @create: 2021-08-19 16:59
 **/
@Entity(name = "orders")
@Table(name = "orders")
@Getter
@Setter
@Access(AccessType.FIELD)
@Accessors(chain = true)
public class Order extends AbstractEntity<Long> {
    private BigDecimal amount;
    @ElementCollection
    private List<OrderItem> items;
    @ManyToOne
    private User user;

    @Override
    public String toString() {
        assert this.getId() != null;
        return this.getId().toString();
    }
}
